<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>PCMS内容管理系统</title>
<link href="<?php echo $_tpl['css']; ?>admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="ckeditor/config.js"></script>
<script type="text/javascript" src="<?php echo $_tpl['js']; ?>jquery.js"></script>
<script language="javascript">
window.onload = function()
{
	CKEDITOR.replace( 'content',
	{
		toolbar : [
    ['Source','Undo','Redo','Find','Replace','SelectAll','RemoveFormat'],
    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
    ['Link','Unlink','Anchor'],
    ['Image','Table','HorizontalRule','SpecialChar','PageBreak'],
    ['Font','FontSize'],
    ['TextColor','BGColor'],
    ['Maximize', 'ShowBlocks']
],
		fullPage : false,
		width:	630,
		filebrowserBrowseUrl : '/admin/ckfinder/ckfinder.html',
		filebrowserImageBrowseUrl : '/admin/ckfinder/ckfinder.html?Type=upload',
		filebrowserFlashBrowseUrl : '/admin/ckfinder/ckfinder.html?Type=upload',
		filebrowserUploadUrl : '/admin/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=upload',
		filebrowserImageUploadUrl : '/admin/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=upload',
		filebrowserFlashUploadUrl : '/admin/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=upload'
	});
};

function check()
{
	var item = document.getElementById( "cate_id" );

	if ( item.options[item.selectedIndex].value == -1 )
	{
		alert( "请选择栏目" );
		item.focus();
		return false;
	}

	var item = document.getElementById( "type" );

	if ( item.options[item.selectedIndex].value == 0 )
	{
		alert( "请选择类型" );
		item.focus();
		return false;
	}

	var item = document.getElementById( "htmlfile" );

	if ( item.value == "" )
	{
		alert( "请选择文件" );
		item.focus();
		return false;
	}


	document.getElementById( "submit" ).disabled = true;
	return true;
}
</script>
</head>
<body>
<center><h3>添加内容</h3></center>
<table width="90%" border="0" align="center" cellpadding="5" cellspacing="1">
<form id="apply1" method="get">
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727">请选择栏目</td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><select id="cate_id" name="cate_id"><option value="-1">请选择</option><?php
	if ( isset( $cate_data ) && is_array( $cate_data ) )
	{
		$cate_id = isset( $cate_id ) ? $cate_id : 0;
		foreach ( $cate_data as $index => $value )
		{
			$selected = '';
			if ( $value['id'] == $cate_id )
			{
				$selected = 'selected';
			}
			echo '<option value="' . $value['id'] . '" ' . $selected . '>' . str_repeat( '&nbsp;&nbsp;', $value['level'] ) . $value['cname'] . '</option>';
		}
	}
	?></select></td>
  </tr>
  <tr>
    <td height="20" colspan="16" align="center" bgcolor="#000000">
		<table width="40%">
			<tr align="center">
				<td><input class="btn2" type="submit" id="submit" value="提交"></td>
				<td><input class="btn2" type="button" value="返回" onclick="window.location.href='<?php echo $reference; ?>'"></td>
			</tr>
		</table>
	</td>
  </tr>
</form>
</table>

<?php
	if ( isset( $cate_id ) && $cate_id > 0 )
	{
?>
<table width="90%" border="0" align="center" cellpadding="5" cellspacing="1">
<form id="apply" method="post" enctype="multipart/form-data" onsubmit="return check()">
<input type="hidden" name="reference" value="<?php echo $reference; ?>">
<input type="hidden" name="cate_id" value="<?php echo $cate_id; ?>">
<?php
	if ( isset( $module_data ) )
	{
		$s = '';
		$html_module = load( 'biz.html_module' );
		foreach( $module_data as $key=>$value)
		{
			$token = '<tr><td width="20%" height="20" align="right" bgcolor="#272727">' . $value['cname'] . '</td><td width="62%" height="20" colspan="2" align="left" bgcolor="#272727">' . $html_module->form_render( $value ) . '</td></tr>' . "\r\n";
			$s .= $token;
		}
		echo $s;
	}
?>
  <tr>
    <td height="20" colspan="16" align="center" bgcolor="#000000">
		<table width="40%">
			<tr align="center">
				<td><input class="btn2" type="submit" id="submit" value="提交"></td>
				<td><input class="btn2" type="button" value="返回" onclick="window.location.href='<?php echo $reference; ?>'"></td>
			</tr>
		</table>
	</td>
  </tr>
</form>
</table>
<?php
}
?>
</body>
</html>